//
//  Auction_MainCellHeaderRecommend_View_WX.m
//  ZITHER
//
//  Created by weixin on 2019/5/28.
//  Copyright © 2019 weixn. All rights reserved.
//

#import "Auction_MainCellHeaderRecommend_View_WX.h"

@implementation Auction_MainCellHeaderRecommend_View_WX

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        [self setCornerRadiusWithRadius:8 isMasks:YES];
        [self setUI];
    }
    return self;
}

-(void)setModel:(specialSaleSceneidList *)model{
    _model = model;
    [self.userPic sd_setImage:model.userAvatar];
    [self.showPic sd_setImage:model.cover];

    self.userName.text = model.userNick;
    self.titleLab.text = model.title;
    if (model.priceDiscount.length>0 ) {
        self.PriceLab.text = [NSString stringWithFormat:@"¥%@",model.priceDiscount];
    }else{
       self.PriceLab.text = @"¥ ？？？";
    }
}

-(void)setUI{
    
    [self addSubview:self.userPic];
    [self addSubview:self.userName];
    [self addSubview:self.showPic];
    [self addSubview:self.type1];
    [self addSubview:self.type2];
    [self addSubview:self.titleLab];
    [self addSubview:self.titleSubLab];
    [self addSubview:self.PriceLab];
    
    [self.userPic mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(15);
        make.top.equalTo(self).offset(15);
        make.height.width.mas_equalTo(30);
    }];
    
    [self.userName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.userPic.mas_right).offset(10);
        make.centerY.equalTo(self.userPic).offset(0);
        make.height.mas_equalTo(15);
    }];
    
    [self.showPic mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self).offset(0);
        make.top.equalTo(self.userPic.mas_bottom).offset(10);
        make.width.mas_equalTo(kScreenW-60);
        make.height.mas_equalTo((kScreenW-60)/312.0*146);
    }];
    
    [self.type1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.equalTo(self.showPic).offset(10);
        make.width.mas_equalTo(60);
        make.height.mas_equalTo(20);
    }];
    
    [self.type2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.showPic).offset(10);
        make.left.equalTo(self.type1.mas_right).offset(10);
        make.width.mas_equalTo(60);
        make.height.mas_equalTo(20);
    }];
    
    [self.titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(15);
        make.top.equalTo(self.showPic.mas_bottom).offset(10);
        make.right.equalTo(self).offset(-15);
    }];
    
    [self.titleSubLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(15);
        make.top.equalTo(self.titleLab.mas_bottom).offset(12);
    }];
    
    [self.PriceLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.titleSubLab.mas_right).offset(5);
        make.centerY.equalTo(self.titleSubLab).offset(0);
        make.height.mas_equalTo(20);
    }];

}

- (BaseImageV *)userPic{
    if (!_userPic) {
        _userPic = [BaseImageV initCustom:CGRectZero contentMode:2];
        _userPic.backgroundColor = [UIColor redColor];
        [_userPic setCornerRadiusWithRadius:15 isMasks:YES];
    }
    return _userPic;
}

- (BaseLab *)userName{
    if (!_userName) {
        _userName = [BaseLab initCustomLab:@"商户名称" color:HexColor(0x333333) font:[UIFont fontWithName:@"PingFangSC-Semibold" size:14]];
    }
    return _userName;
}

- (BaseImageV *)showPic{
    if (!_showPic) {
        _showPic = [BaseImageV initCustom:CGRectZero contentMode:2];
        _showPic.backgroundColor = [UIColor redColor];
    }
    return _showPic;
}

- (BaseLab *)type1{
    if (!_type1) {
        _type1 = [BaseLab initCustomLab:@"标签一" color:[UIColor whiteColor] font:[UIFont fontWithName:@"PingFang-SC-Regular" size:12]];
        _type1.hidden = YES;
        _type1.backgroundColor = RGBA(153, 153, 153, 0.4);
    }
    return _type1;
}


- (BaseLab *)type2{
    if (!_type2) {
        _type2 = [BaseLab initCustomLab:@"标签二" color:[UIColor whiteColor] font:[UIFont fontWithName:@"PingFang-SC-Regular" size:12]];
        _type2.hidden = YES;
        _type2.backgroundColor = RGBA(153, 153, 153, 0.4);
    }
    return _type2;
}

-(BaseLab *)titleLab{
    if (!_titleLab) {
        _titleLab = [BaseLab initCustomLab:@"介绍介绍介绍123sdq" color:HexColor(0x333333) font:[UIFont fontWithName:@"PingFang-SC-Heavy" size:15]];
    }
    return _titleLab;
}

-(BaseLab *)titleSubLab{
    if (!_titleSubLab) {
        _titleSubLab = [BaseLab initCustomLab:@"特卖价" color:HexColor(0xff6f6f) font:[UIFont fontWithName:@"PingFang-SC-Regular" size:12]];
    }
    return _titleSubLab;
}

-(BaseLab *)PriceLab{
    if (!_PriceLab) {
        _PriceLab = [BaseLab initCustomLab:@"$123123" color:HexColor(0xff6f6f) font:[UIFont fontWithName:@"PingFangSC-Semibold" size:20]];
    }
    return _PriceLab;
}

/**
    userPic;
    userName
    showPic;
    type1;
    type2;
    titleLab;
    titleSubLab;
    PriceLab;
  */

@end
